package leetcode.秋招.华为OD;

import org.omg.CORBA.MARSHAL;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author ：zsy
 * @date ：Created 2022/9/19 21:22
 * @description：
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int m = in.nextInt();
        int n = in.nextInt();
        int[] works = new int[n];
        for (int i = 0; i < works.length; i++) {
            works[i] = in.nextInt();
        }
        Arrays.sort(works);
        int min = Integer.MIN_VALUE;
        int[] res = new int[m];
        for (int i = 0; i < works.length; i++) {
            res[i % m] += works[i];
            min = Math.max(min, res[i%m]);
        }
        System.out.println(min);
    }
}
